package java6681.login;

import java.util.Scanner;

class User6681 {
    private String name;
    private String password;

    public User6681() {

    }

    public User6681(String name, String password) {
        this.name = name;
        this.password = password;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public String getPassword() {
        return password;
    }

    public String toString() {
        return name;
    }
}

class Login6681 {
    private User6681[] users;
    private int max;

    public Login6681() {
        max = 3;
        users = new User6681[2];
        users[0] = new User6681();
        users[0].setName("zhang");
        users[1] = new User6681();
        users[1].setPassword("123qwe");
    }

    public Login6681(int max) {
        max = 3;
        users = new User6681[2];
        users[0] = new User6681();
        users[0].setName("zhang");
        users[1] = new User6681();
        users[1].setPassword("123qwe");
    }

    //表示可以重试的最大次数
    public int getMax() {
        return max;
    }

    public boolean check6681(String name, String pwd) {
        boolean isFlag = false;
        if (name.equals(users[0].getName()) && pwd.equals(users[1].getPassword())
                && pwd.equalsIgnoreCase(String.valueOf(users[1].getPassword()))) {
            isFlag = true;
        } else {
            isFlag = false;
        }
        return isFlag;
    }
}

public class DemoLogin6681 {
    public static void main(String[] args) {
        Login6681 login6681 = new Login6681();
        for (int i = 0; i < login6681.getMax(); i++) {
            Scanner sc = new Scanner(System.in);
            System.out.println("输入用户名：");
            String name = sc.nextLine();
            System.out.println("输入密码：");
            String pwd = sc.nextLine();

            boolean flag = login6681.check6681(name, pwd);
            if (flag == true) {
                System.out.println("登录成功");
                break;
            } else {
                if (login6681.getMax() - i == 0) {
                    System.out.println("登录失败，账户锁定");
                } else {
                    System.out.println("登录失败" + (login6681.getMax() - i) + "次");
                }
            }
        }

    }

}



